using IronXL;
using System.Linq;
WorkBook workBook = WorkBook.Load("sample.xls");
WorkSheet workSheet = workBook.WorkSheets.First();
// Get range from worksheet
var range = workSheet["A1:A8"];
// Apply sum of all numeric cells within the range
decimal sum = range.Sum();
// Apply average value of all numeric cells within the range
decimal avg = range.Avg();
// Identify maximum value of all numeric cells within the range
decimal max = range.Max();
// Identify minimum value of all numeric cells within the range
decimal min = range.Min();
Imports IronXL
Imports System.Linq
Private workBook As WorkBook = WorkBook.Load("sample.xls")
Private workSheet As WorkSheet = workBook.WorkSheets.First()
' Get range from worksheet
Private range = workSheet("A1:A8")
' Apply sum of all numeric cells within the range
Private sum As Decimal = range.Sum()
' Apply average value of all numeric cells within the range
Private avg As Decimal = range.Avg()
' Identify maximum value of all numeric cells within the range
Private max As Decimal = range.Max()
' Identify minimum value of all numeric cells within the range
Private min As Decimal = range.Min()
Install-Package IronXL.Excel
C#에서 Excel 집계 함수 마스터하기
위의 코드 예제는 Excel 스프레드시트의 셀 범위에서 쉽게 집계 값을 얻는 방법을 보여줍니다. 그러나 숫자가 아닌 셀은 제외된다 점에 유의하세요.
합계
메서드 Sum()는 선택된 셀 범위의 총합을 반환합니다.
평균
메서드 Average()는 선택된 셀 범위의 평균을 반환합니다.
최소
메서드 Min()는 선택된 셀 범위에서 가장 작은 숫자를 반환합니다.
최대
메서드 Max()는 선택된 셀 범위에서 가장 큰 숫자를 반환합니다.
위의 기능은 단일/다중 행이나 열에도 적용할 수 있어 더 많은 유연성을 제공합니다. 행 및 열 선택에 대해 더 알아보세요.